﻿using MODEL;
using SysHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SysController
{
    public static class BaseController
    {
        #region 1.0 当前机器名 - static string HostName
        /// <summary>
        /// 1.0 当前机器名
        /// </summary>
        private static string HostName
        {
            get { return System.Net.Dns.GetHostName(); }
        }
        #endregion

        #region 1.1 当前机器运行商城店铺信息 - static List<UP_GetMwsModel_Result> MwsInfoList
        /// <summary>
        /// 1.1 当前机器运行商城店铺信息
        /// </summary>
        private static List<UP_GetMwsModel_Result> MwsInfoList { get; set; }
        #endregion

        #region 1.2 当前商城店铺信息是不是空 + static bool MwsInfoListIsNotNull()
        /// <summary>
        /// 1.2 当前商城店铺信息是不是空
        /// </summary>
        /// <returns></returns>
        private static bool MwsInfoListIsNotNull()
        {
            if (MwsInfoList != null)
                return true;
            else
                return false;
        }
        #endregion

        #region  1.3 获取商城店铺信息 + static bool GetMwsInfoList()
        /// <summary>
        /// 1.3 获取商城店铺信息
        /// </summary>
        /// <returns></returns>
        private static bool GetMwsInfoList()
        {
            try
            {
                System.Data.Objects.ObjectParameter[] param = { new System.Data.Objects.ObjectParameter("HostName", HostName) };
                MwsInfoList = OperateContext.CurrentContext.BllSession.IObject_BLL.ExecProcedure<UP_GetMwsModel_Result>("UP_GetMwsModel", param);
                return MwsInfoList != null ? true : false;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        #endregion

        #region  当前服务器允许运行的 Mws 信息 + static List<UP_GetMwsModel_Result> Mws()
        /// <summary>
        /// 当前服务器允许运行的 Mws 信息
        /// </summary>       
        /// <returns></returns>
        public static List<UP_GetMwsModel_Result> Mws()
        {
            if (MwsInfoList == null)
            {
                if (GetMwsInfoList())
                {
                    return MwsInfoList;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return MwsInfoList;
            }
        } 
        #endregion


    }

}
